<?php
// +----------------------------------------------------------------------
// | KITEGO-Admin「开箱即用」「人人全栈」
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2024 https://www.kitego.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed KITEGO并不是自由软件，未经许可不能去掉KITEGO相关版权
// +----------------------------------------------------------------------
// | Author: KITEGO Team <bd@kitego.cn>
// +----------------------------------------------------------------------

namespace kitego\extend\storage\impl;

use kitego\extend\storage\Storage;

class LocalImpl extends Storage
{
    public function __construct($config)
    {
        $this->config = $config;
    }

    public function upload($path)
    {
        $info = $this->file->move($path, $this->fileName);
        if (empty($info)) {
            $this->error = $this->file->getError();
            return false;
        }

        return true;
    }

    public function delete($path)
    {
        $check = strpos($path, '/');
        if ($check !== false && $check == 0) {
            // 文件所在目录
            $path = substr_replace($path, "", 0, 1);
        }
        $filePath = public_path() . "{$path}";

        return !file_exists($filePath) || unlink($filePath);
    }

    public function water($path)
    {
        // TODO: Implement water() method.
    }
}